<template>
  <div>
    <button @click="handleReset" type="button" class="btn btn-warning">
      reset
    </button>
    <button type="button" class="btn btn-primary">结算</button>
  </div>
</template>

<script>
export default {
  name: 'Button',
  props: {
    goodsList: {
      type: Array,
    },
  },
  data() {
    return {
      list: null,
    };
  },
  methods: {
    handleReset() {
      this.list = this.goodsList.sort((a, b) => {
        if (a.name < b.name) {
          return -1;
        }
        if (a.name > b.name) {
          return 1;
        }
        return 0;
      });
      this.$emit('listReset', this.list);
    },
  },
};
</script>

<style lang="scss" scoped>
button {
  margin-right: 10px;
}
</style>
